<?php
/**
 * Created by PhpStorm.
 * User: CYJiao
 * Date: 6/4/15
 * Time: 19:28
 */
?>

<div class="easyui-layout" data-options="border:false,fit:true" style="margin-left:5px;">
    <div class="easyui-accordion" data-options="border:true,fit:true">
        <script>
            $(function(){
                var patientList = $('#patientList');
                $(window).resize(function(){
                    patientList.datagrid('resize', {
                        width:function(){
                            return document.body.clientWidth;
                        },
                        height:function(){
                            return document.body.clientHeight;
                        }
                    });
                });

                // patient list data list style
                patientList.datagrid({
                    url: '<?php echo CController::createUrl('doctor/getPatientList',array('pk_doctor_id'=>Yii::app()->session['id'])) ;?>',
                    fit: true,
                    striped: true,
                   
                    remoteSort: false,
                    fitColumns: true,
                    nowrap: false,
                    border: false,
                    singleSelect: true,
                    columns:
                        [[
                            {
                                title:'姓名',
                                field:'true_name',
                                sortable:true,
                                width:55
                            },{
                                title:'性别',
                                field:'gender',
                                sortable:true,
                                width:30
                            },
                            
                            {
                                title:'ID',
                                field:'pk_outpatient_id'
                            }
                        ]],
                    toolbar: '#toolbar',
                    onDblClickRow :function(rowIndex,rowData){
                        addTab(rowData.true_name+"_"+rowData.username,'<?php echo Yii::app()->request->baseUrl; ?>/index.php?r=patient/getPatientsMainAccordion&pk_outpatient_id='+rowData.pk_outpatient_id,'icon-patient');
                    }
                });

                // patient list hide column - pk_outpatient_id
                patientList.datagrid(
                    'hideColumn', 'pk_outpatient_id'
                );

                //patient list detail viewer
                // patientList.datagrid({
                //     view: detailview,
                //     detailFormatter:function(index,row){
                //         return '<div class="ddv" style="padding:5px 0"></div>';
                //     },
                //     onExpandRow: function(index,row){
                //         var ddv = $(this).datagrid('getRowDetail',index).find('div.ddv');
                //         ddv.panel({
                //             border:false,
                //             cache:false,
                //             href:'<?php echo Yii::app()->request->baseUrl; ?>/index.php?r=doctor/getOutPatientDetail&pk_outpatient_id='+row.pk_outpatient_id,
                //             onLoad:function(){
                //                 $('#patientList').datagrid('fixDetailRowHeight',index);
                //             }
                //         });
                //         $('#patientList').datagrid('fixDetailRowHeight',index);
                //     }
                // });

                // patient list filter for all columns
                patientList.datagrid('enableFilter');
            });

            // refresh patient list
            function refresh(){
                $('#patientList').datagrid('load');
            }
        </script>

        <div class="easyui-layout" data-options="border:false,fit:true">
            <div data-options="region:'center',fit:true,border:false" style="overflow: hidden;">
                <table id="patientList" data-options="border:false,fit:true" style="height: 500px;">
                </table>
                <div id="toolbar">
                    <table style="border-spacing:0">
                        <tr style="margin-bottom: 5px;">
                            <td>
                                <div class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="addTab('添加患者','<?php echo CController::createUrl('patient/add'); ?>','icon-addPatient')">添加</div>
                                <div class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onclick="refresh();">刷新</div>
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
